package com.example.xiaoxueqixiangmu.jiemian;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.xiaoxueqixiangmu.R;

import java.util.ArrayList;
import java.util.HashMap;


public class MyPaAdapter extends BaseAdapter {
    private Context context;
    private ArrayList<HashMap<String,String>> dataArray;
    MyPaAdapter(Context context, ArrayList<HashMap<String, String>> dataArray){
        this.context= context;
        this.dataArray = dataArray;
    }

    @Override
    public int getCount() {
        return dataArray.size();
    }

    @Override
    public Object getItem(int position) {
        return dataArray.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        View item = layoutInflater.inflate(R.layout.item_pa, null, false);

        TextView txtPaName = item.findViewById(R.id.txtPaName);
        TextView txtTrainNo = item.findViewById(R.id.txtTrainNo);
        TextView txtStartDate = item.findViewById(R.id.txtStartDate);
        TextView txt = item.findViewById(R.id.txt);

        HashMap<String, String> hashMap = dataArray.get(position);

        txtPaName.setText(hashMap.get("paName"));
        txtTrainNo.setText(hashMap.get("trainNo"));
        txtStartDate.setText(hashMap.get("startDate"));
        txt.setText(hashMap.get("txt"));

        return item;
    }
}
